浏览量 4433
2018/12/03 02:38
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>if</title>
</head>
<body>
<div id="vue-app">
<h1> 实例化多个对象</h1>
<div id="vue-app-one">
<p> {{ title }}</p>
<p> {{ greet }}</p>
</div>
<div id="vue-app-two">
<p> {{ title }}</p>
<p> {{ greet }}</p>
<button v-on:click="change">change one</button>
</div>
<script src="/static/js/vue.min.js"></script>
<script>
var one = new Vue({
el: "#vue-app-one",
data: {
title: "app-one"
},
methods: {},
computed: {
greet:function () {
return "computed app one"
}
}
});
var two = new Vue({
el: "#vue-app-two",
data: {
title: "app-two"
},
methods: {
change:function () {
one.title="changed app one"
}
},
computed: {
greet:function () {
return "computed app two"
}
}
});
two.title="changed app two";
</script>
</body>
</html>
上一篇 搜索 下一篇